<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Cadastro de Vegetação</title>
</h:head>

<h:body>
	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />

			<h:form prependId="true" id="formCadastro">
				<br />
				<br />
				<br />
				<br />

				<p:hotkey bind="f4" update=":formPesquisa:tabelaVegetacao"
					oncomplete="dlg.show()" upprocess="@all" immediate="true"
					action="#{vegetacaoBacking.carregarVegetacao}" />

				<p:panel header="Cadastro de Vegetação" styleClass="size"
					toggleable="true"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">

					<br />
					<div align="center">
						<h:panelGrid columns="3">
							<h:outputText value="Descrição: " />
							<p:inputText
								value="#{vegetacaoBacking.vegetacaoSalvar.descricao}" size="50"
								required="true" requiredMessage="Informe a vegetação!" />
							<p:commandButton value="F4" icon="ui-icon-search" oncomplete="dlg.show()"
								actionListener="#{vegetacaoBacking.carregarVegetacao}"
								update=":formPesquisa:tabelaVegetacao" upprocess="@all"
								immediate="true" />

						</h:panelGrid>
					</div>
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Salvar" update=":formCadastro"
								icon="ui-icon-disk" actionListener="#{vegetacaoBacking.salvar}" />
							<p:commandButton value="Cancelar" icon="ui-icon-cancel"
								action="#{vegetacaoBacking.reset}" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>
			<h:form id="formPesquisa">
				<p:dialog id="pesquisaVegetacao" widgetVar="dlg" appendToBody="true" modal="true"
					header="Pesquisar Vegetações" closable="true" resizable="false"
					showEffect="clip" hideEffect="clip">

					<p:dataTable id="tabelaVegetacao" var="veg"
						value="#{vegetacaoBacking.listaVegetacao}" paginator="true"
						rows="5">
						<f:facet name="header">
							<h:outputText value="Vegetações Cadastradas" />
						</f:facet>

						<p:column headerText="Código">
							<h:outputText value="#{veg.codigoFormatado()}" />
						</p:column>

						<p:column headerText="Descrição">
							<h:outputText value="#{veg.descricao}" />
						</p:column>
						<p:column headerText="Ações">
							<div align="center">
								<h:panelGrid columns="2">
									<p:commandButton icon="ui-icon-pencil" onclick="dlg.hide()"
										ajax="false" action="#{vegetacaoBacking.preparaAlteracao}">
										<f:setPropertyActionListener
											target="#{vegetacaoBacking.vegetacaoSelecionada}"
											value="#{veg}" />
									</p:commandButton>

									<p:commandButton icon="ui-icon-close"
										onclick="dlgDelete.show()">
										<f:setPropertyActionListener
											target="#{vegetacaoBacking.vegetacaoSelecionada}"
											value="#{veg}" />
									</p:commandButton>

								</h:panelGrid>
							</div>
						</p:column>

					</p:dataTable>
				</p:dialog>
				<p:dialog id="confirmaDelete" widgetVar="dlgDelete"
					header="Deletar Registro" closable="true" width="230"
					resizable="false" showEffect="clip" hideEffect="clip">
					<div align="center">
						<h:outputText value="Deseja realmente excluir esse registro?" />
						<h:panelGrid columns="2">
							<p:commandButton value="Sim" onsuccess="dlgDelete.hide()"
								actionListener="#{vegetacaoBacking.delete}"
								update=":formPesquisa:pesquisaVegetacao" process="@all"
								immediate="true" />
							<p:commandButton value="Não" onclick="dlgDelete.hide()" />
						</h:panelGrid>
					</div>
				</p:dialog>
			</h:form>
		</ui:define>
	</ui:decorate>
</h:body>
</html>